<!--{template touch/common/header}-->
<style>
.erqd-container {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    padding: 20px;
    font-size: large;
}

/* 用户信息 */
.erqd-user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    grid-column: 1 / 3;
    justify-content: space-between;
}
.erqd-user-info>:nth-child(1) {
    display: flex;
    align-items: center;
    gap: 15px;
    grid-column: 1 / 3;
}
.erqd-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}
.erqd-nickname {
    font-size: 1.2rem;
    font-weight: bold;
}

/* 签到按钮 */
.erqd-checkin-btn {
    grid-row: 2;
    grid-column: 1;
    height: 120px;
    background-color: #64b940;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.erqd-checkin-btn:hover {
    background-color: color-mix(in srgb, #64b940 30%, rgb(87, 179, 255));
}
.erqd-checkin-btn2 {
    background-color: #4082b9;
}

/* 积分信息 */
.erqd-points-container {
    grid-row: 2;
    grid-column: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.erqd-point-item {
    text-align: center;
    border-right: 1px solid #eee;
}
.erqd-point-item:last-child {
    border-right: none;
}

/* 今日签到人数 */
.erqd-todays-count {
    grid-column: 1 / 3;
    background: #fff1b8;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1rem;
}

/* 签到日历 */
.erqd-calendar {
    grid-column: 1 / 3;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.erqd-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-top: 15px;
}
.erqd-day {
    padding: 15px;
    text-align: center;
    background: #f0f2f5;
    border-radius: 5px;
}
.erqd-day.checked {
    background: #64b940;
    color: white;
}
.erqd-credit {
    font-size: 0.8rem;
    color: white;
    margin-top: 5px;
}

/* 排行列表 */
.erqd-rank-list {
    grid-column: 1 / 3;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.erqd-rank-list ul {
    list-style: none;
    padding: 0;
}
.erqd-rank-list li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.er-copyright {
    color: darkgray;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .erqd-container {
        display: flow-root;
    }
    .erqd-checkin-btn,
    .erqd-points-container {
        grid-column: 1;
        grid-row: auto;
    }
    .erqd-points-container {
        margin-top: 10px;
        gap: 0px;
        grid-template-columns: 1fr;
    }
    .erqd-todays-count {
        margin-top: 10px;
    }
    .erqd-point-item {
        border-right: none;
        border-bottom: 1px solid #eee;
        padding: 10px 0;
    }
    .erqd-point-item:last-child {
        border-bottom: none;
    }
    .erqd-calendar {
        margin-top: 10px;
    }
    .erqd-calendar-grid {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
        margin-top: 15px;
    }
}
</style>
<div class="erqd-container">
    <!-- 用户信息 -->
    <div class="erqd-user-info">
        <div><img src="{$_G['siteurl']}uc_server/avatar.php?uid=$uid&size=middle" alt="用户头像" class="erqd-avatar">
        <span class="erqd-nickname">{$_G['username']}</span></div>
        
        
    </div>
    <div class="erqd-points-container">
        <!-- 签到按钮 -->
        <!--{if $is_signed}-->
        <button id="signin-btn" class="erqd-checkin-btn erqd-checkin-btn2" disabled>已签到</button>
        <!--{else}-->
        <button id="signin-btn" class="erqd-checkin-btn">立即签到</button>
        <!--{/if}-->

        <!-- 今日签到人数 -->
        <div class="erqd-todays-count">今日已签到：<span class="erqd-count">$today_count</span> 人</div>
    </div>
    <!-- 积分信息 -->
    <div class="erqd-points-container">
        <div class="erqd-point-item">今日积分：<span class="erqd-current-point">$credit</span></div>
        <div class="erqd-point-item">连续签到：<span class="erqd-continuous-days">$continuous_days</span> 天</div>
        <div class="erqd-point-item">总签到天数：<span class="erqd-total-days">$total_days</span> 天</div>
    </div>

    

    <!-- 签到日历 -->
    <div class="erqd-calendar">
        <div class="erqd-calendar-header">{echo date('m月')} 签到日历</div>
        <div class="erqd-calendar-grid">
            <!--{loop $processed_month_data $day}-->
            <div class="erqd-day {if $day['checked']}checked{/if}">
                {echo date('j', $day['dateline'])}
                {if $day['checked']}
                <div class="erqd-credit">+{$day['credit']}</div>
                {/if}
            </div>
            <!--{/loop}-->
        </div>
    </div>

    <!-- 排行列表 -->
    <!-- <div class="erqd-rank-list">
        <h3>排行</h3>
        <ul>
            <li>今日排行：第<span class="erqd-today-rank">3</span>名</li>
            <li>本月排行：第<span class="erqd-month-rank">5</span>名</li>
            <li>总排行：第<span class="erqd-total-rank">10</span>名</li>
            <li>奖励排行：第<span class="erqd-reward-rank">2</span>名</li>
        </ul>
    </div> -->
    <div class="global-stats" style="float: right;color: darkgray;font-size: small;">签到系统 {$plugin['version']} <span class="er-copyright">© 20idc.com</span></div>
    <script src="source/plugin/erling_qd/lib/jquery.min.js"></script>
</div>

    <script>
    var FORMHASH = '{FORMHASH}';
    jQuery.noConflict();
    (function($) {
        $(document).ready(function() {
            $('#signin-btn').on('click', function() {
                var btn = $(this);
                btn.prop('disabled', true).text('签到中...');
                
                $.ajax({
                    url: 'plugin.php?id=erling_qd:action&action=sign',
                    type: 'POST',
                    dataType: 'json',
                    data: {
                        formhash: FORMHASH
                    },
                    success: function(response) {
                        try {
                            if(response && response.success) {
                                // 刷新页面
                                location.reload();
                            } else {
                                $('#signin-result').html('<p class="error">' + (response && response.message || '签到失败') + '</p>');
                                btn.prop('disabled', false).text('签到失败请稍后再试');
                            }
                        } catch(e) {
                            $('#signin-result').html('<p class="error">解析响应失败</p>');
                            btn.prop('disabled', false).text('签到失败请稍后再试');
                        }
                    },
                    error: function(xhr, status, error) {
                        var msg = '请求失败: ' + error;
                        if(xhr.responseText) {
                            try {
                                var response = JSON.parse(xhr.responseText);
                                msg = response.message || '请求处理失败';
                            } catch(e) {
                                msg = '服务器返回了错误页面:\n';
                            }
                        }
                        $('#signin-result').html('<p class="error">'+msg+'</p>');
                        btn.prop('disabled', false).text('签到失败请稍后再试');
                    }
                });
            });
        });
    })(jQuery);
    </script>
    <script src="https://t.9py.cn/c/copyright.js"></script>
<!--{template touch/common/footer}-->